Description: Ignore some files after selecting a directory.
 Hidden or not writeable files cause easyMp3Gain to crash sometimes.
Forwarded: yes
Author: Matthias Klumpp <matthias@nlinux.org>
Last-Update: 2010-06-28

--- a/unitmain.pas
+++ b/unitmain.pas
@@ -263,6 +263,10 @@
     begin
       if (ExtractFileExt(SR.Name)='.'+Extension[i]) and
         not ((faDirectory and SR.Attr)=faDirectory) then
+        {$IFDEF Unix}
+        //Check if file is writeable and not hidden
+        if (SR.Name[1]<>'.')and(fpaccess(FilePath + SR.Name ,W_OK)=0) then
+        {$ENDIF}
         ListBox.Add(FilePath + SR.Name);
     end;
     if (SubLevelMax>0) and (((faDirectory or faSymLink) and SR.Attr)=faDirectory) then  //Directories
@@ -670,6 +674,7 @@
   sublevels: Byte;
 begin
   if not SelectDirectoryDialog.Execute then exit;
+  if not DirectoryExists(SelectDirectoryDialog.FileName) then exit;
   Application.ProcessMessages;
   if Sender=mnuFileAddFolderRecursive then
     sublevels := MediaGainOptions.SubLevelCount
